package com.logica.mdm.webfrontend.models.party;

import java.io.Serializable;

import org.apache.commons.lang.StringUtils;

import com.logica.mdm.webfrontend.dao.beans.PartyResultBean;

/**
 * Party search result.
 * @author Fabien Crespel <fabien.crespel@logica.com>
 */
public class PartySearchResult extends PartyResultBean implements Serializable {
	private static final long serialVersionUID = 1L;

	private String addUrl;
	private String showUrl;
	private String editUrl;

	public PartySearchResult() {
		super();
	}

	public PartySearchResult(PartyResultBean party) {
		super(party);
	}

	public String getAddUrl() {
		return addUrl;
	}

	public void setAddUrl(String addUrl) {
		this.addUrl = addUrl;
	}

	public String getShowUrl() {
		return showUrl;
	}

	public void setShowUrl(String showUrl) {
		this.showUrl = showUrl;
	}

	public String getEditUrl() {
		return editUrl;
	}

	public void setEditUrl(String editUrl) {
		this.editUrl = editUrl;
	}
	
	/**
	 * Method that return the address as a  concatenation
	 * of streetNumber, streetType and streetName
	 * @return the result address
	 */
	public String getAddress() {
		String result = StringUtils.join(new String[]{getStreetNumber(), getStreetType(), getStreetName()}, " ");
		
		return result.trim().replaceAll(" +", " "); // removes all the unnecessary spaces
	}

}
